<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<form action="login.html" method="post" enctype="application/x-www-form-urlencoded">
    <input type="text" name="username" placeholder="请输入用户名" >
    <br> <br>
    <input type="password" name="password" placeholder="请输入密码" >
    <br> <br>
    <button type="submit">
        登录
    </button>

</form>
<script>
    $('form').submit(function (ev) {
        //阻止form表单的默认事件
        ev.preventDefault()
        console.log('已经阻止了')
        //获取表单数据，自动将其转换成字符串序列化对
        //name=value&name=value
        var data = $(this).serialize();
        //简写写法
        $.post('index.html',data,function (resData) {

        })
    })
</script>
</body>
</html>